package demo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class TestMain {
    
    public static void test1()
    {
        System.out.println("test1...");
        Axe steelaxe = new SteelAxe();  
        Axe stoneaxe = new StoneAxe();  
        WoodCutter c1 = new WoodCutter();
        
                    // cloze 设值注入  WoodCutter c1通过set方法传参注入被调用的对象stoneaxe
                    // cloze c1 调用 useAxe();
        
                    // cloze 声明一个WoodCutter c2 并通过构造注入方式传入 steelaxe
                    // cloze c2.调用 useAxe();


        ApplicationContext ctx = new ClassPathXmlApplicationContext("bean_lec01.xml");
        //  在 beam_lec01.xml文件中 设值注入配置 demo.WoodCutter woodcutter01，注入demo.StoneAxe
        Person p1 = (Person)ctx.getBean("woodcutter01");
        p1.useAxe();
        // 在 beam_lec01.xml文件中 构造注入配置 woodcutter02，注入demo.SteelAxe
        Person p2 = (Person)ctx.getBean("woodcutter02");
        p1.useAxe();
    }
    public static void main(String[] args) {
        
        System.out.println("***My name is Zhao! This is My Code.***");
        test1();
        
    }
}